package utils

import "net/http"

type ResultResp struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

const (
	SUCCESS = http.StatusOK
	ERROR   = http.StatusBadRequest
)

func SuccessWithData(data interface{}) ResultResp {
	return ResultResp{Code: SUCCESS, Msg: "成功", Data: data}
}

func SuccessWithMsg(msg string) ResultResp {
	return ResultResp{Code: SUCCESS, Msg: msg, Data: nil}
}

func SuccessWithMsgAndData(msg string, data interface{}) ResultResp {
	return ResultResp{Code: SUCCESS, Msg: msg, Data: data}
}

func ErrorWithMsg(msg string) ResultResp {
	return ResultResp{Code: ERROR, Msg: msg, Data: nil}
}

func ErrorWithoutAnything() ResultResp {
	return ResultResp{Code: ERROR, Msg: "失败", Data: nil}
}
